package com.ruoyi.utils;

import java.time.LocalDate;

/**
 * gps 存在闰秒  与utc 时间不一致
 * 将已知的修改 时间列出来
 */
public class GpsTimeUtll {
    /**
     * # GPS闰秒时间
     * dates = np.array([datetime(1981, 7, 1), datetime(1982, 7, 1), datetime(1983, 7, 1), datetime(1985, 7, 1),
     *          datetime(1987, 12, 31), datetime(1989, 12, 31), datetime(1990, 12, 31), datetime(1992, 7, 1),
     *          datetime(1993, 7, 1), datetime(1994, 7, 1), datetime(1995, 12, 31), datetime(1997, 7, 1),
     *          datetime(1998, 12, 31), datetime(2005, 12, 31), datetime(2008, 12, 31), datetime(2012, 7, 1),
     *          datetime(2015, 7, 1), datetime(2017, 12, 31), datetime(2024, 12, 31)])
     *
     *          2017.1.1 TAI-UTC=37s GPS-UTC=18s
     */

    public static int secBetweenGpsAndUtc(LocalDate now) {
        //时间 每隔一段时间公布
        if (now.isAfter(LocalDate.of(2024,12,31))) {
            return 19;
        }else if (now.isAfter(LocalDate.of(2016, 12, 31))) {
            return 18;
        }else if (now.isAfter(LocalDate.of(2015,6,30))) {
            return 17;
        }else if (now.isAfter(LocalDate.of(2012,6,30))) {
            return 16;
        }else if (now.isAfter(LocalDate.of(2008,12,31))) {
            return 15;
        }else if (now.isAfter(LocalDate.of(2005, 12, 31))) {
            return 14;
        }else if (now.isAfter(LocalDate.of(1998, 12, 31))) {
            return 13;
        }else if (now.isAfter(LocalDate.of(1997, 6, 30))) {
            return 12;
        }else if (now.isAfter(LocalDate.of(1995, 12, 31))) {
            return 11;
        }else if (now.isAfter(LocalDate.of(1994, 6, 30))) {
            return 10;
        }else if (now.isAfter(LocalDate.of(1993, 6, 30))) {
            return 9;
        }else if (now.isAfter(LocalDate.of(1992, 6, 30))) {
            return 8;
        }else if (now.isAfter(LocalDate.of(1990, 12, 31))) {
            return 7;
        }else if (now.isAfter(LocalDate.of(1989, 12, 31))) {
            return 6;
        }else if (now.isAfter(LocalDate.of(1987, 12, 31))) {
            return 5;
        }else if (now.isAfter(LocalDate.of(1985, 6, 30))) {
            return 4;
        }else if (now.isAfter(LocalDate.of(1983, 6, 30))) {
            return 3;
        }else if (now.isAfter(LocalDate.of(1982, 6, 30))) {
            return 2;
        }else if (now.isAfter(LocalDate.of(1981, 6, 30))) {
            return 1;
        }else  {
            return 0;
        }
    }
}
